home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-in_the_mag-
/
pdselect
/
ispell_yam
/
rexx
/
ispell_all.rexx
next >
Wrap
OS/2 REXX Batch file
|
2000-03-08
|
6KB
|
165 lines
/*-------------------------------------------------------------------------------------------------
iSpell_all.rexx 1.97
Brecht Machiels <darklite@flashmail.com>
Lorens Johansson <SnorsleX@Home.se>
Roger 'Ben' Bennett <bennett@ntl.net.com>
---------------------------------------------------------------------------------------------------
$VER: iSpell_all v1.97
$AUTHOR: Copyright © 1999 Brecht Machiels, Lorens Johansson, Roger 'Ben' Bennett
$DESCRIPTION: Simple interface for YAM & iSpell
--> OPTIONS <------------------------------------------------------------------------------------*/
BINPATH = "iSpell:bin/"
/*-----------------------------------------------------------------------------------------------*/
OPTIONS RESULTS
a = OPEN('envvar', 'ENV:ISPELLYAM', 'R')
IF a = 0 THEN DO
ADDRESS 'AREXX' 'YAM:Rexx/iSpell_lang'
DO UNTIL a = 1
a = OPEN('envvar', 'ENV:ISPELLYAM', 'R')
END
END
language = READLN('envvar')
CLOSE('envvar')
IF SHOW('P', 'IRexxSpell') THEN DO
a = OPEN('currentlang', 'ENV:ISPELLMR', 'R')
IF a = 0 THEN DO
ADDRESS 'IRexxSpell' 'EXIT'
EXIT
END
IF language ~= READLN('currentlang') THEN DO
ADDRESS 'IRexxSpell' 'EXIT'
PRAGMA('S', 10240)
ADDRESS 'COMMAND' 'run <nil: >nil: 'BINPATH'iSpell -d'language' -r >nil: <nil:'
ADDRESS 'COMMAND' 'waitforport IRexxSpell'
END
CLOSE('currentlang')
END
ELSE DO
PRAGMA('S', 10240)
ADDRESS 'COMMAND' 'run <nil: >nil: 'BINPATH'iSpell -d'language' -r >nil: <nil:'
ADDRESS 'COMMAND' 'waitforport IRexxSpell'
ADDRESS 'COMMAND' 'setenv ISPELLMR 'language
END
ADDRESS 'YAM' 'WRITEEDITOR "'POSITION sof'"'
prev = 'zzz'
check = 'vvv'
DO FOREVER
prev = check
ADDRESS 'YAM' 'WRITEEDITOR "'GETCURSOR column'"'
wordpos = result + 1
ADDRESS 'YAM' 'WRITEEDITOR GETLINE'
line = result
IF POS(' ', SUBSTR(line, wordpos)) ~= 0 THEN
check = SUBSTR(line, wordpos, POS(' ', SUBSTR(line, wordpos)))
ELSE check = STRIP(SUBSTR(line, wordpos), 'T', '0a'X)
check = STRIP(STRIP(check), 'B', '.,;:"''[]{}()<>?!')
IF check = '' THEN LEAVE
SELECT
WHEN RIGHT(prev, LENGTH(prev) - POS(' ', TRANSLATE(prev, ' ', '.,;:/_&|@"#''§^ç<>{}°©1234567890[]®', ' '))) = check THEN
ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
WHEN VERIFY(check, '.,;:/_&|@"#''§^ç<>{}°©1234567890[]()®', 'M') ~= 0 THEN
ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
OTHERWISE DO
IF VERIFY(SUBSTR(check, 2), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'M') = 0 THEN
ADDRESS 'IRexxSpell' 'QUICKCHECK 'check''
ELSE ADDRESS 'IRexxSpell' 'QUICKCHECK 'TRANSLATE(check, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')''
IF result = 'bad' THEN DO
ADDRESS 'YAM' 'REQUEST "'check' is spelled incorrectly!" "_Continue|_Lookup|_Accept|A_dd|_Stop"'
SELECT
WHEN result = 1 THEN ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
WHEN result = 2 THEN DO
ADDRESS 'IRexxSpell' 'CHECK 'check''
r = result
r1 = substr(r,1,1)
r3 = substr(r,3)
SELECT
WHEN r1 = '&' THEN
IF words(r) = 2 THEN DO
r3 = SUBSTR(r3, POS(':', r3) + 2)
ADDRESS 'YAM' 'REQUEST "Choose a replacement for 'check':" "'r3'|_Cancel"'
IF result = 1 THEN DO
CALL ReplaceWord(r3)
END
END
ELSE DO
allwords = SUBSTR(r3, POS(':', r3) + 2)
x = 0
DO UNTIL allwords = ''
x = x + 1
posi = POS(',', allwords)
IF posi ~= 0 THEN DO
temp.x = LEFT(allwords, posi - 1)
allwords = SUBSTR(allwords, posi + 2)
END
ELSE DO
temp.x = allwords
allwords = ''
END
END
nums = x
choose = temp.1
DO x = 2 TO nums
choose = choose||"|"||temp.x
END
ADDRESS 'YAM' 'REQUEST "Choose a replacement for 'check':" "'choose'|_Cancel"'
IF result ~= 0 THEN DO
DO x = 1 TO nums
IF result = x THEN newword = temp.x
END
CALL ReplaceWord(newword, LENGTH(check))
END
END
WHEN r1 = '#' THEN ADDRESS 'YAM' 'REQUEST "Could not find anything for 'check'!" "_Ok"'
OTHERWISE NOP
END
ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
END
WHEN result = 3 THEN DO
ADDRESS 'IRexxSpell' 'ACCEPT 'TRANSLATE(check, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')''
ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
END
WHEN result = 4 THEN DO
ADDRESS 'IRexxSpell' 'ADD 'TRANSLATE(check, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')''
ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
END
WHEN result = 0 THEN EXIT
END
END
ELSE ADDRESS 'YAM' 'WRITEEDITOR "'NEXT word'"'
END
END
END
ADDRESS 'YAM' 'REQUEST "End of document reached" " _Ok | _Exit ISpell "'
SELECT
WHEN result = 0 THEN ADDRESS 'IRexxSpell' 'EXIT'
OTHERWISE NOP
END
EXIT
ReplaceWord:
newword = ARG(1)
length = ARG(2)
ADDRESS 'YAM' 'WRITEEDITOR "'MARK on'"'
DO count = 1 TO length
ADDRESS 'YAM' 'WRITEEDITOR "'CURSOR right'"'
END
ADDRESS 'YAM' 'WRITEEDITOR "'ERASE'"'
ADDRESS 'YAM' 'WRITEEDITOR "'TEXT newword'"'
RETURN